{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1. Create S3 Bucket (If Not Already Created)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "export S3_BUCKET=sagemaker-us-west-2-231218423789\n",
      "                           PRE amazon-reviews-pds/\n",
      "                           PRE athena/\n",
      "                           PRE estimator-training-pipeline-2020-09-05-16-19-43/\n",
      "                           PRE estimator-training-pipeline-2020-09-05-17-19-35/\n",
      "                           PRE kubeflow-pipeline-sagemaker-1599322018/\n",
      "                           PRE mnist_kmeans_example/\n",
      "                           PRE mxnet-training-2020-09-08-16-25-06-939/\n",
      "                           PRE mxnet-training-2020-09-08-16-26-17-357/\n",
      "                           PRE pipeline_sklearn_processing/\n",
      "                           PRE processing_code/\n",
      "                           PRE sagemaker-scikit-learn-2020-10-28-16-23-54-437/\n",
      "                           PRE sm_bert_viz/\n",
      "                           PRE tensorflow-training-2020-10-28-16-45-14-788/\n",
      "                           PRE tensorflow-training-2020-10-28-16-45-38-395/\n",
      "                           PRE tensorflow-training-2020-10-28-16-46-28-369/\n",
      "                           PRE tensorflow-training-2020-10-28-16-59-10-041/\n",
      "                           PRE tensorflow-training-2020-10-28-17-01-12-396/\n",
      "                           PRE training-pipeline-2020-09-05-16-19-31/\n",
      "                           PRE training-pipeline-2020-09-05-17-19-24/\n",
      "                           PRE training_code/\n",
      "Completed\n"
     ]
    }
   ],
   "source": [
    "%%bash\n",
    "\n",
    "export S3_BUCKET=sagemaker-$(aws configure get region)-$(aws sts get-caller-identity | jq -r '.Account')\n",
    "echo \"export S3_BUCKET=${S3_BUCKET}\" | tee -a ~/.bash_profile\n",
    "\n",
    "# Create a new S3 bucket and upload the dataset. \n",
    "aws s3 ls s3://$S3_BUCKET || aws s3 mb s3://${S3_BUCKET}\n",
    "\n",
    "echo \"Completed\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2. Verify S3_BUCKET Env Variable"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "sagemaker-us-west-2-231218423789\n"
     ]
    }
   ],
   "source": [
    "%%bash\n",
    "\n",
    "source ~/.bash_profile\n",
    "\n",
    "echo \"${S3_BUCKET}\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3. Verify S3_BUCKET Bucket Creation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                           PRE amazon-reviews-pds/\n",
      "                           PRE athena/\n",
      "                           PRE estimator-training-pipeline-2020-09-05-16-19-43/\n",
      "                           PRE estimator-training-pipeline-2020-09-05-17-19-35/\n",
      "                           PRE kubeflow-pipeline-sagemaker-1599322018/\n",
      "                           PRE mnist_kmeans_example/\n",
      "                           PRE mxnet-training-2020-09-08-16-25-06-939/\n",
      "                           PRE mxnet-training-2020-09-08-16-26-17-357/\n",
      "                           PRE pipeline_sklearn_processing/\n",
      "                           PRE processing_code/\n",
      "                           PRE sagemaker-scikit-learn-2020-10-28-16-23-54-437/\n",
      "                           PRE sm_bert_viz/\n",
      "                           PRE tensorflow-training-2020-10-28-16-45-14-788/\n",
      "                           PRE tensorflow-training-2020-10-28-16-45-38-395/\n",
      "                           PRE tensorflow-training-2020-10-28-16-46-28-369/\n",
      "                           PRE tensorflow-training-2020-10-28-16-59-10-041/\n",
      "                           PRE tensorflow-training-2020-10-28-17-01-12-396/\n",
      "                           PRE training-pipeline-2020-09-05-16-19-31/\n",
      "                           PRE training-pipeline-2020-09-05-17-19-24/\n",
      "                           PRE training_code/\n"
     ]
    }
   ],
   "source": [
    "%%bash\n",
    "\n",
    "source ~/.bash_profile\n",
    "\n",
    "aws s3 ls s3://${S3_BUCKET}\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%javascript\n",
    "Jupyter.notebook.save_checkpoint();\n",
    "Jupyter.notebook.session.delete();"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "conda_python3",
   "language": "python",
   "name": "conda_python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
